package com.tinygone.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    LoadBalancerClient loadBalancerClient;

    @GetMapping("/test2")
    public String test2() {
        ServiceInstance si = loadBalancerClient.choose("eureka-movie");
        String str = si.getHost() + ":" + si.getPort() + "-" + si.getServiceId();
        System.err.println(str);
        return str;
    }
}
